package top.atcra.rpc.protection.loadBalancer;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum LoadBalanceType {
    round_robin((byte) 0),
    consistent_hash((byte) 1),
    min_response_time((byte) 2),
    ;
    private final byte id;
    private static final Map<Byte, LoadBalanceType> map = new HashMap<>() {{
        for (LoadBalanceType type : LoadBalanceType.values()) {
            put(type.getId(), type);
        }
    }};

    public static LoadBalanceType valueOf(byte id) {
        return map.get(id);
    }
}
